/*****Log*****/
clear
cd "C:\Users\Joshua\Dropbox\Work\Networks and Economic Perceptions\Data and Do Files"
	/*the above needs to be updated to where you have the data/do files*/
	
log using "Online Appendix B Output.smcl", replace
	/*the log file is in format .smcl, but can be read via txt editor*/

set more off


/***********************************************************************
************************************************************************
************************************************************************
This do file contains the needed to replicate Online Appendix B, where
we investigate the influence of control variables. 

For each survey, the code will load and clean the data at hand using the
commands included in the survey cleaning .do files and then do the 
analyses in question. For those wishing to use this to replicate the analyses, 
you will need to update the cd command below to point to where your data
and .do files are located. 

Also note that there are some STATA modules that need to be installed:

ssc install estout, replace
ssc install grc1leg, replace
ssc install blindschemes, replace
ssc install combomarginsplot, replace

************************************************************************
************************************************************************
***********************************************************************/




/***********************************************
************************************************
		Deficit Knowledge
************************************************
***********************************************/

/****************************************
*****************************************
		2000 ANES
*****************************************
****************************************/	


clear
do "Data Cleaning - 2000 ANES.do"

eststo clear
eststo: logit def_knowl i.partisan##c.disagree_total [pweight = V000002a]

		margins, dydx(disagree_total) by(partisan)
		margins partisan, at(disagree_total=(-4(1)4))  saving(knowl_2000a, replace)
					
eststo: logit def_knowl i.partisan##c.disagree_total i.gender i.race ///
	 age educ income  [pweight = V000002a]
	
		margins, dydx(disagree_total) by(partisan)
		margins partisan, at(disagree_total=(-4(1)4))  saving(knowl_2000b, replace)
		
eststo: logit def_knowl i.partisan##c.disagree_total names1 disc_knowl interest i.gender i.race ///
	i.marital age educ income nfc1 evaluate1 [pweight = V000002a]
		
		margins, dydx(disagree_total) by(partisan)
		margins partisan, at(disagree_total=(-4(1)4)) saving(knowl_2000c, replace)
	
/*Figure*/

combomarginsplot  knowl_2000a knowl_2000b knowl_2000c, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2000 ANES: Knowledge", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")

graph save "2000 ANES Knowledge - Comparing Models", replace
graph export "2000 ANES Knowledge - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_2000KNOWL_MODEL.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted: V000002a") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Deficit Knowledge, 2000 ANES: Comparing Models")

eststo clear

/****************************************
*****************************************
		2008-9 ANES
*****************************************
****************************************/	

clear
do "Data Cleaning - 2008 Panel.do"
set more off


rename partisan_9rev partisan

/****May 2009****/
eststo clear
eststo: logit def_knowl17 i.partisan##c.disagree_total  [pweight= WGTPP17]
	
	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3)) saving(knowl_Maya, replace)
			
			
eststo: logit def_knowl17 i.partisan##c.disagree_total  i.gender i.race  ///
	age educ income  [pweight= WGTPP17]
	
	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3)) saving(knowl_Mayb, replace)
			

eststo: logit def_knowl17 i.partisan##c.disagree_total numgiven1 network_interest interest_w9 i.gender i.race i.marital ///
	age educ income nfc1 evaluate1  [pweight= WGTPP17]
	

	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3)) saving(knowl_Mayc, replace)
			
			
/*Figure*/

combomarginsplot knowl_Maya knowl_Mayb knowl_Mayc, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2009 ANES (May): Knowledge", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")

		
graph save "2009 May Knowledge - Comp. Models", replace
graph export "2009 May Knowledge - Comp. Models.png", replace

		
/*Table*/
esttab using TABLE_MAYKNOWL_MODEL.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP17") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Deficit Knowledge, 2008-2009 (May) ANES: Comparing Models")

eststo clear

/*******July 2009******/
eststo clear

eststo: logit def_knowl19 i.partisan##c.disagree_total [pweight= WGTPP19]
	
	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3))  saving(knowl_Julya, replace)
	
eststo: logit def_knowl19 i.partisan##c.disagree_total ///
		i.gender i.race  age educ income  [pweight= WGTPP19]
	
	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3))  saving(knowl_Julyb, replace)

eststo: logit def_knowl19 i.partisan##c.disagree_total numgiven1 network_interest interest_w9 ///
		i.gender i.race i.marital age educ income nfc1 evaluate1 [pweight= WGTPP19]
	
	margins, dydx(disagree_total) by(partisan)
	margins partisan, at(disagree_total=(-3(1)3))  saving(knowl_Julyc, replace)
	
			
/*Figure*/

combomarginsplot knowl_Julya knowl_Julyb knowl_Julyc, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2009 ANES (July): Knowledge", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")

		
graph save "2009 July Knowledge - Comparing Models", replace
graph export "2009 July Knowledge - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_JULYKNOWL_MODEL.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP19") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Deficit Knowledge, 2008-2009 (July) ANES: Comparing Models")
	
eststo clear



/****July, by May Knowledge***/
eststo clear

eststo: logit def_knowl19 i.partisan##c.disagree_total i.def_knowl17 [pweight= WGTPP19]
		
	margins, dydx(disagree_total) by(partisan) at(def_knowl17=(0))
	margins partisan, at(disagree_total=(-3(1)3) def_knowl17=(0)) saving(knowl_JulyCa, replace)
	
	
eststo: logit def_knowl19 i.partisan##c.disagree_total i.def_knowl17 i.gender ///
		i.race  age educ income  [pweight= WGTPP19]

	margins, dydx(disagree_total) by(partisan) at(def_knowl17=(0))
	margins partisan, at(disagree_total=(-3(1)3) def_knowl17=(0)) saving(knowl_JulyCb, replace)

eststo: logit def_knowl19 i.partisan##c.disagree_total i.def_knowl17 numgiven1 network_interest interest_w9 ///
	i.gender i.race i.marital age educ income nfc1 evaluate1 [pweight= WGTPP19]
	
	margins, dydx(disagree_total) by(partisan) at(def_knowl17=(0))
	margins partisan, at(disagree_total=(-3(1)3) def_knowl17=(0)) saving(knowl_JulyCc, replace)
	
/*Figure*/

combomarginsplot knowl_JulyCa knowl_JulyCb knowl_JulyCc, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2009 ANES (July, Incorr in May): Knowledge", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")

		
graph save "2009 July (Incorr) Knowledge (up) - Comparing Models", replace
graph export "2009 July (Incorr) Knowledge (up) - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_JULYINCORRKNOWL_MODEL.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP19") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Deficit Knowledge, 2008-2009 (July, Incorrect in May) ANES: Comparing Models")
	
eststo clear

/***********************************************
************************************************
		Economic Evaluations
************************************************
***********************************************/

				
/****************************************
*****************************************
		1992 CNEP
*****************************************
****************************************/	

*data cleaning*
clear
do "Data Cleaning - 1992 CNEP.do"
set more off
	

eststo: ologit retro i.partisan##c.disagree_total 

	margins, dydx(disagree_total) by(partisan) predict(outcome(3))
	margins partisan, at(disagree_total=(-5(1)5)) predict(outcome(3))  saving(eval_1992a, replace)
	

eststo: ologit retro i.partisan##c.disagree_total  age educ ///
	income i.gender i.race   
	
	margins, dydx(disagree_total) by(partisan) predict(outcome(3))
	margins partisan, at(disagree_total=(-5(1)5)) predict(outcome(3))  saving(eval_1992b, replace)
	
			
eststo: ologit retro i.partisan##c.disagree_total numgiven disc_knowl news_att age educ ///
	income i.gender i.race i.employed i.marital 
	
	margins, dydx(disagree_total) by(partisan) predict(outcome(3))
	margins partisan, at(disagree_total=(-5(1)5)) predict(outcome(3))  saving(eval_1992c, replace)
	
/*Figure*/

combomarginsplot eval_1992a eval_1992b eval_1992c, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("1992 CNEP: Evaluations", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "1992 CNEP Eval - Comparing Models", replace
graph export "1992 CNEP Eval - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_1992CNEPEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP19") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, 1992 CNEP: Comparing Models")
	
eststo clear
			
								
			
		
/****************************************
*****************************************
		2000 ANES
*****************************************
****************************************/	

clear
do "Data Cleaning - 2000 ANES.do"
set more off

eststo clear
eststo: ologit econ_post3 i.partisan##c.disagree_total  [pweight = V000002a]
	
		margins, dydx(disagree_total) by(partisan) predict(outcome(3)) 
		margins partisan, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2000a, replace)
	
eststo: ologit econ_post3 i.partisan##c.disagree_total  age educ income ///
	i.gender i.race [pweight = V000002a]
	
		margins, dydx(disagree_total) by(partisan) predict(outcome(3)) 
		margins partisan, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2000b, replace)

eststo: ologit econ_post3 i.partisan##c.disagree_total names1 disc_knowl interest age educ income ///
	i.gender i.race i.employed i.marital nfc1 evaluate1 [pweight = V000002a]
	
		margins, dydx(disagree_total) by(partisan) predict(outcome(3)) 
		margins partisan, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2000c, replace)

/*Figure*/

combomarginsplot eval_2000a eval_2000b eval_2000c, scheme(plotplainblind)  by(partisan) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2000 ANES", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "2000 ANES Eval - Comparing Models", replace
graph export "2000 ANES Eval - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_2000ANESEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:V000002") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, 2000 ANES: Comparing Models")
	
eststo clear
				
	
/****************************************
*****************************************
		2002 ANES
*****************************************
****************************************/				 
		
*data cleaning
clear
do "Data Cleaning - 2002 ANES.do"
set more off

eststo clear
eststo: ologit retro2002_3 i.partisan2000##c.disagree_total  [pweight=WT02PRE]

		margins, dydx(disagree_total) by(partisan2000) predict(outcome(3))
		margins partisan2000, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2002a, replace)

eststo: ologit retro2002_3 i.partisan2000##c.disagree_total  ///
	 age2002 educ income2002 i.gender i.race [pweight=WT02PRE]

		margins, dydx(disagree_total) by(partisan2000) predict(outcome(3))
		margins partisan2000, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2002b, replace)
		
		
eststo: ologit retro2002_3 i.partisan2000##c.disagree_total names1 disc_knowl ///
	follow age2002 educ income2002 i.gender i.race i.employed i.marital nfc1 evaluate1 [pweight=WT02PRE]

		margins, dydx(disagree_total) by(partisan2000) predict(outcome(3))
		margins partisan2000, at(disagree_total=(-4(1)4)) predict(outcome(3)) saving(eval_2002c, replace)
		
/*Figure*/

combomarginsplot eval_2002a eval_2002b eval_2002c, scheme(plotplainblind)  by(partisan2000) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2002 ANES", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "2002 ANES Eval - Comparing Models", replace
graph export "2002 ANES Eval - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_2002NESEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:V000002") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, 2002 ANES: Comparing Models")
	
eststo clear		
		
				 
					
					
/****************************************
*****************************************
		2006 ANES
*****************************************
****************************************/	

*data cleaning
clear
do "Data Cleaning - 2006 ANES.do"
set more off

eststo clear
eststo: ologit retro i.partisan2004##c.disagree_total [pweight = V06P002]	
	
		margins, dydx(disagree_total) by(partisan2004) predict(outcome(3))
		margins partisan2004, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_2006a, replace)
		
eststo: ologit retro i.partisan2004##c.disagree_total   ///
	age educ income i.gender i.race  [pweight = V06P002]	
	
		margins, dydx(disagree_total) by(partisan2004) predict(outcome(3))
		margins partisan2004, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_2006b, replace)

eststo: ologit retro i.partisan2004##c.disagree_total names disc_interest follow04 ///
	age educ income i.gender i.race i.employed i.marital nfc1 evaluate1 [pweight = V06P002]	
	
		margins, dydx(disagree_total) by(partisan2004) predict(outcome(3))
		margins partisan2004, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_2006c, replace)

/*Figure*/

combomarginsplot eval_2006a eval_2006b eval_2006c, scheme(plotplainblind)  by(partisan2004) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("2006 ANES", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "2006 ANES Eval - Comparing Models", replace
graph export "2006 ANES Eval - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_2006NESEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:V06P002") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, 2006 ANES: Comparing Models")
			
	
eststo clear		
		

/****************************************
*****************************************
		2008-9 ANES
*****************************************
****************************************/	

clear
do "Data Cleaning - 2008 Panel.do"
set more off


/***May***/
eststo clear

eststo: ologit w17_retro i.partisan_9rev##c.disagree_total  [pweight= WGTPP17]
	
	margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
	margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Maya, replace)
	
		
eststo: ologit w17_retro i.partisan_9rev##c.disagree_total  	///
	age educ income i.gender i.race  [pweight= WGTPP17]
	
	margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
	margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Mayb, replace)
	
		
eststo: ologit w17_retro i.partisan_9rev##c.disagree_total c.numgiven network_interest interest_w9 	///
	age educ income i.gender i.race i.empl_w11a i.marital nfc1 evaluate1 [pweight= WGTPP17]
	
	margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
	margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Mayc, replace)
	
/*Figure*/

combomarginsplot eval_Maya eval_Mayb eval_Mayc, scheme(plotplainblind)  by(partisan_9rev) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("May 2009", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "May 2009 ANES Eval (up) - Comparing Models", replace
graph export "May 2009 ANES Eval (up)  - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_MAYANESEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP17") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, May 2009: Comparing Models")
			
	
eststo clear		
				
/***July***/

eststo clear
	
eststo: ologit w19_retro i.partisan_9rev##c.disagree_total  [pweight= WGTPP19]
	
		margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
		margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Julya, replace)
	
eststo: ologit w19_retro i.partisan_9rev##c.disagree_total  ///
		age educ income i.gender i.race [pweight= WGTPP19]
	
		margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
		margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Julyb, replace)
		
eststo: ologit w19_retro i.partisan_9rev##c.disagree_total c.numgiven network_interest interest_w9 ///
		age educ income i.gender i.race i.empl_w11a i.marital nfc1 evaluate1 [pweight= WGTPP19]
	
		margins, dydx(disagree_total) by(partisan_9rev) predict(outcome(3))
		margins partisan_9rev, at(disagree_total=(-3(1)3)) predict(outcome(3)) saving(eval_Julyc, replace)

		
/*Figure*/

combomarginsplot eval_Julya eval_Julyb eval_Julyc, scheme(plotplainblind)  by(partisan_9rev) plot2opts(msymbol(T)) plot3opts(msymbol(S)) ///
		byopts(title("July 2009", size(medsmall))) labels("Model 1" "Model 2" "Model 3")  legend(rows(1)) xtitle(, size(small)) ytitle("")
		
graph save "July 2009 ANES Eval (up)  - Comparing Models", replace
graph export "July 2009 ANES Eval (up)  - Comparing Models.png", replace

		
/*Table*/
esttab using TABLE_JULYANESEVAL_MODELS.rtf, onecell replace label se star(+ 0.10 * 0.05 ** 0.01) nobaselevels ///
			mtitles("Model 1" "Model 2" "Model 3") addnotes("Analyses are weighted:WGTPP19") pr2 aic bic ///
			title({\b Table O.} "Disagreement and Retro Evals, July 2009: Comparing Models")
			
	
eststo clear			
				
				
log close
		
					
						
					
					
					
					
					
					
					
					
					
					
